package com.fuxian.dao.mybatisImpl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.stereotype.Repository;

import com.fuxian.dao.UserLessonDao;
import com.fuxian.model.Userlessons;

@Repository
public class UserLessonDaoMybatisImpl implements UserLessonDao {

	@Resource
	private SqlSessionTemplate sqlSessionTemplate;
	public void addUserLesson(Userlessons userlessons) {
	sqlSessionTemplate.insert("addUserlessons", userlessons);

	}

	public void deleteUserLessonById(int userId, int lessonId) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("user_id", userId);
		map.put("lesson_id", lessonId);
sqlSessionTemplate.delete("deleteUserlessonsById", map);
	}

	public void modifyUserLesson(Userlessons userlessons) {
		sqlSessionTemplate.update("modifyUserlessons", userlessons);

	}

	public List<Userlessons> selectAllUserlesson(int start, int size) {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("start", start);
		map.put("size", size);
		return sqlSessionTemplate.selectList("selectAllUserlessons", map);
	}

}
